# coding=utf-8
from lib.Item.Equipment.Body import Body
from lib.Item.Equipment.Foot import Foot
from lib.Item.Equipment.Hand import Hand
from lib.Item.Equipment.Head import Head
from lib.Item.Equipment.Weapon import Weapon


class Equipments(object):
    def __init__(self, weapon, head, body, foot, hand):
        super(Equipments, self).__init__()
        self.weapon = weapon
        self.head = head
        self.body = body
        self.foot = foot
        self.hand = hand

        if not isinstance(self.weapon, Weapon):
            raise ValueError('必须为武器类型！')
        if not isinstance(self.head, Head):
            raise ValueError('必须为头盔类型！')
        if not isinstance(self.body, Body):
            raise ValueError('必须为盔甲类型！')
        if not isinstance(self.foot, Foot):
            raise ValueError('必须为鞋子类型！')
        if not isinstance(self.hand, Hand):
            raise ValueError('必须为手套类型！')

        self.list_equipment = [self.weapon, self.head, self.body, self.foot, self.head]

    def attack(self):
        atk = 0
        for equip in self.list_equipment:
            atk += equip.attack
        return atk

    def attack_physical(self):
        atk_physical = 0
        for equip in self.list_equipment:
            atk_physical += equip.attack_physical
        return atk_physical

    def attack_magic(self):
        atk_magic = 0
        for equip in self.list_equipment:
            atk_magic += equip.attack_magic
        return atk_magic

    def defense(self):
        defense = 0
        for equip in self.list_equipment:
            defense += equip.defense
        return defense

    def defense_physical(self):
        defense = 0
        for equip in self.list_equipment:
            defense += equip.defense_physical
        return defense

    def defense_magic(self):
        defense = 0
        for equip in self.list_equipment:
            defense += equip.defense_magic
        return defense

    def physical_armor(self):
        physical_armor = 0
        for equip in self.list_equipment:
            physical_armor += equip.physical_armor
        return physical_armor

    def magic_armor(self):
        magic_armor = 0
        for equip in self.list_equipment:
            magic_armor += equip.magic_armor
        return magic_armor

    def stamina(self):
        stamina = 0
        for equip in self.list_equipment:
            stamina += equip.stamina
        return stamina

    def strengt(self):
        strengt = 0
        for equip in self.list_equipment:
            strengt += equip.strengt
        return strengt

    def agility(self):
        agility = 0
        for equip in self.list_equipment:
            agility += equip.agility
        return agility

    def intellect(self):
        intellect = 0
        for equip in self.list_equipment:
            intellect += equip.intellect
        return intellect

    def dodge(self):
        dodge = 0
        for equip in self.list_equipment:
            dodge += equip.dodge
        return dodge

    def combo(self):
        combo = 0
        for equip in self.list_equipment:
            combo += equip.combo
        return combo

    def critical(self):
        critical = 0
        for equip in self.list_equipment:
            critical += equip.critical
        return critical

    def counter(self):
        counter = 0
        for equip in self.list_equipment:
            counter += equip.counter
        return counter
